package com.liao.product.controller;

import com.liao.common.entity.product.ProductAttributeEntity;
import com.liao.common.utils.PageUtils;
import com.liao.product.service.ProductAttributeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 商品关键属性表
 *
 * @author liao
 * @email 2858015963@qq.com
 * @date 2025-02-28 23:29:28
 */
@RestController
@RequestMapping("product/productattribute")
public class ProductAttributeController {
    @Autowired
    private ProductAttributeService productAttributeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public PageUtils<ProductAttributeEntity> list(@RequestParam Map<String, Object> params) {
        return productAttributeService.queryPage(params);

    }


    /**
     * 信息
     */
    @RequestMapping("/info/{attributeId}")
    public ProductAttributeEntity info(@PathVariable("attributeId") Integer attributeId) {
        return productAttributeService.getById(attributeId);

    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public void save(@RequestBody ProductAttributeEntity productAttribute) {
        productAttributeService.save(productAttribute);

    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public void update(@RequestBody ProductAttributeEntity productAttribute) {
        productAttributeService.updateById(productAttribute);

    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public void delete(@RequestBody Integer[] attributeIds) {
        productAttributeService.removeByIds(Arrays.asList(attributeIds));

    }

}
